package com.simplemall.account.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.simplemall.account.service.IAccountService;
import com.simplemall.account.service.WxAccountService;
import com.simplemall.micro.serv.common.bean.account.AccAddress;
import com.simplemall.micro.serv.common.bean.account.User;
import com.simplemall.micro.serv.common.bean.account.WxAccount;
import com.simplemall.micro.serv.common.constant.SystemConstants;

@RestController
@RequestMapping("/wxAccount")
public class WxAccountController {

	@Autowired
	WxAccountService wxAccountService;
	
	@RequestMapping("create")
	public String createWxAccount(@RequestParam(required = true) @PathVariable("userJsonStr") String userJsonStr) {
		Boolean result = wxAccountService.createWxAccount(userJsonStr);
		return result ? SystemConstants.Code.SUCCESS : SystemConstants.Code.FAIL;
	}
	
	@RequestMapping(value = "update", method = RequestMethod.POST)
	public String updateWxAccount(@RequestParam(required = true) @PathVariable("userJsonStr") String userJsonStr) {
		Boolean result = wxAccountService.updateWxAccount(userJsonStr);
		return result ? SystemConstants.Code.SUCCESS : SystemConstants.Code.FAIL;
	}
	
	@RequestMapping(value = "getWxAccountInfo/{openid}", method = RequestMethod.POST)
	public WxAccount getWxAccountInfo(@PathVariable("openid") String openid){
		return wxAccountService.getWxAccountInfo(openid);
	}
}
